from tortoise import fields
from tortoise.models import Model

class ScheduleTasksDB(Model):
    id = fields.IntField(pk=True, auto_generated=True)
    schedule_id = fields.IntField()
    run_time = fields.TextField()
    created_at = fields.DatetimeField(auto_now_add=True)

    def to_dict(self):
        # Convert model instance to dictionary
        return {
            "id": self.id,
            "schedule_id": self.schedule_id,
            "run_time": self.run_time,
            "created_at": self.created_at.strftime("%Y/%m/%d %H:%M:%S"),
        }

    class Meta:
        table = "schedule_tasks"